cc.Class({
    extends: cc.Component,
    editor: {
        executeInEditMode: true
    },
    properties: {
        material: cc.Material,

        grayLevel: {
            range: [0, 1, 0.001],
            slide: true,
            default: [],
            type: cc.Float,
            notify: function () {
                if (!this.material) {
                    return;
                }

                this.material.setProperty("grayLevel0", this.grayLevel[0]);
                this.material.setProperty("grayLevel1", this.grayLevel[1]);
                this.material.setProperty("grayLevel2", this.grayLevel[2]);
                this.material.setProperty("grayLevel3", this.grayLevel[3]);
                this.node.getComponent(cc.Sprite).setMaterial(0, this.material);

                cc.log("notify", this.graylevel);
            }.bind(this)
        },
        grayColors: {
            default: [],
            type: cc.Color,
            notify: function () {
                if (!this.material) { 
                    return;
                }
                this.material.setProperty("color0", this.grayColors[0]);
                this.material.setProperty("color1", this.grayColors[1]);
                this.material.setProperty("color2", this.grayColors[2]);
                this.material.setProperty("color3", this.grayColors[3]);
                this.node.getComponent(cc.Sprite).setMaterial(0, this.material);
                cc.log("notify", this.grayColors);
            }.bind(this)
        },
    },

    onLoad() {
        this.material.setProperty("grayLevel0", this.grayLevel[0]);
        this.material.setProperty("grayLevel1", this.grayLevel[1]);
        this.material.setProperty("grayLevel2", this.grayLevel[2]);
        this.material.setProperty("grayLevel3", this.grayLevel[3]); 
        this.material.setProperty("color0", this.grayColors[0]);
        this.material.setProperty("color1", this.grayColors[1]);
        this.material.setProperty("color2", this.grayColors[2]);
        this.material.setProperty("color3", this.grayColors[3]);
        this.node.getComponent(cc.Sprite).setMaterial(0, this.material);
    }

});
